#ifndef CAMERAHELPER_H
#define CAMERAHELPER_H


#include <boost/date_time/posix_time/posix_time.hpp>
#include "src/SoftWare/DateTime/DateTime.h"
#include "device/camera.h"
#include "src/pubimp.h"
#include "MU_API.h"
#include "src/Manager/TaskManager.h"
#include "tools.h"

class CameraHelper
{
public:

    static CameraHelper* GetInstance(){
        static QMutex mutex;
        static QScopedPointer<CameraHelper> inst;
        if (Q_UNLIKELY(!inst)) {
            mutex.lock();
            if (!inst) {
                inst.reset(new CameraHelper);
            }
            mutex.unlock();
        }
        return inst.data();
    }

    void handlerDis();      ///处理掉线问题

    void Connect();

    MU_RETURNS reConnect();

    MU_RETURNS CloseCamera();

//    bool isOpened() {
//        return _camera_ptr->IsDeviceConnected();
//    }

    cv::Mat GetPictrue(){
        cv::Mat ret;
        try {
             ret = _camera_ptr->takePicture().clone();
        } catch (...) {
            throw MU_EXPS::EXP_CAMERA_GETBUFFER;
        };

        return ret;
    }
    std::shared_ptr<Camera> _camera_ptr ;

private:
    CameraHelper();
    //std::fstream ofsR ;
    /// 相机

    MU_RETURNS _open();

    // void initMembers();
};

#endif // CAMERAHELPER_H
